Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		Super.OnCreate()
				
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		Return 0
	End
	
	
End


Class TTmpScreen Extends TScreen
	
	Field line0:TLine = New TLine()
	Field line1:TLine = New TLine()
	Field circle:TCircle = New TCircle()
	
	Field l_cross:Bool = False
	Field c_cross:Bool = False
	Field move:Float = 0.0
	Field dir:Float = 1.0
	' START when app is created
	Method Start:Void()
		Self.line0.Create(New TVector2(10,240),New TVector2(630,240))
		Self.line1.Create(New TVector2(320,150),New TVector2(320,250))
		Self.circle.Create(50,320,32)
	End
	
	' main app logic loop update
	Method Update:Void()
		
		'Self.cross =  COLLISION.LinesCross(Self.line0.A.x,Self.line0.A.y,Self.line0.B.x,Self.line0.B.y,Self.line1.A.x,Self.line1.A.y,Self.line1.B.x,Self.line1.B.y)
		Self.l_cross =  COLLISION.LinesCross(Self.line0,Self.line1)
		'Self.c_cross =  COLLISION.LineToCircle(Self.line0.A.x,Self.line0.A.y,Self.line0.B.x,Self.line0.B.y,Self.circle.center.x,Self.circle.center.y,Self.circle.radius)
		Self.c_cross =  COLLISION.LineToCircle(Self.line0,Self.circle)

		
		Self.line0.points.Get(0).y = MOUSE.y
		Self.line0.points.Get(1).y = MOUSE.y
		
		
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		
		If Self.l_cross Then SetColor(255,0,0) Else SetColor(255,255,255)
		Self.line0.Draw()		
		Self.line1.Draw()
		
		If Self.c_cross Then SetColor(255,0,0) Else SetColor(255,255,255)
		Self.circle.Draw()
	End
End
